<template>
	<div>
		<Header></Header> <!-- 子页面公共头部 -->
		<div class="ej_box">
			<div class="ej_center">
				<Crumbs :lmtitle="lmtitle"></Crumbs> <!-- 面包屑导航 -->
				<div class="clear"></div>
				<div class="row">

					<div class="col-md-3">
						<SeniorSearch @search="search"></SeniorSearch>
					</div>
					<div class="col-md-9">
						<div class="ej_content_box">
							<div class="ej_content">
								<div class="ej_content_nav">
									<div class="ej_content_nav_pc">
										<h2 class="ej_content_nav_pc_h2dt">
											<li v-for="item in dhData" @click="link(item.id)"
												:class="form.columnId == item.id?'activexz':''">{{item.name}}</li>
										</h2>

										<div class="clearfix"></div>
									</div>
								</div>
								<div class="ej_content_editor">
									<div class="zcfg_con">



								<div class="zcfg_li2">
									<div class="zcfg_licon">
									<div class="zcfg_li_top">
										<a>
											<div class="zcfg_li_top_fl2">{{title?title.replace("政策法规-",""):""}}</div>

										</a>
									</div>

									<div class="zcfg_nr" style="margin-top: 10px;">
										<div class="zcfg_nrli" v-for="item in tablelist">
											<div class="zcfg_nr_fl2" @click="opendetails(item.id)" style="font-size: 17px;letter-spacing: 0px;">
                                                <i class="iconfont icon-fangkuai"></i>
                                                <p>{{item.title}}</p>
                                                <img src="../assets/images/new.png" class="icon_new"
                                                            v-if="item.newContent==1">
                                                        <img src="../assets/images/top.png" class="icon_top"
                                                            v-if="item.topContent==1">
                                            </div>
                                            <div v-if="item.fileUrl" style="float:left;text-align: right;width: 10%;">{{ item.createTime | moment('YYYY-MM-DD') }}</div>
                                            <div v-else style="float:left;text-align: right;width: 16%;">{{ item.createTime | moment('YYYY-MM-DD') }}</div>

                                            <div class="zcfg_nr_fr2"  v-if="item.fileUrl" @click="down(item.fileUrl)">点击下载</div>


										</div>

									</div>
									</div>
								</div>

							</div>

								</div>

							</div>
						</div>
					</div>

					<div class="clearfix"></div>
				</div>


			</div>
		</div>
		<Foot></Foot> <!-- 网站公共底部 -->
	</div>
</template>
<script>
import {queryFilterColumn} from "@/api/ip"
import Cookies from 'js-cookie'
import Foot from "@/components/foot.vue";
import Crumbs from "@/components/crumbs.vue";
import SeniorSearch from "@/components/seniorsearch.vue";
import { contentApiqueryAll, contentApiQueryByOrg, columnqueryAll } from "@/api/webpage";
import Header from "@/components/header.vue";
export default {
	name: "articlelistpage",
	components: {
		Header,
		Crumbs,
		SeniorSearch,
		Foot
	},
	data() {
		return {
			dhData: [],
			tablelist: [],
			lmtitle: '',
			navId: '',
			form: {
				approval:1,
				orgId:'',
				columnId: '',
				pageNum: 1,
				pageSize: 10000, // 暂时没有加分页 显示所有数据 之前设置的是10
				total: 0
			},
			columnList: [],
            title:''
		};
	},
	// watch: {
	// 	//监听路由地址的改变
	// 	$route: {
	// 		immediate: true,
	// 		handler() {
	// 			if (this.$route.query.id) {//需要监听的参数
	// 				this.form.columnId = this.$route.query.id
	// 				this.navId = this.$route.query.navId
	// 				this.dhData = JSON.parse(Cookies.get('navdata'))[this.$route.query.navId]
	// 				this.lmtitle = JSON.parse(Cookies.get('navdata'))[this.$route.query.navId][0].name
	// 				if (this.$route.query.navId == 12 || this.$route.query.navId == 13) {
	// 					this.getdownlist()
	// 				} else {
	// 					this.getlist()
	// 				}
	// 			}
	// 		}
	// 	}
	// },
	created() {
		this.dhData = JSON.parse(Cookies.get('navdata'))[this.$route.query.navId]
    this.navId = this.$route.query.navId
		this.form.columnId = this.$route.query.id
		this.getlist()
    this.title = this.$route.query.title
		if(this.$route.query.orgId){
			this.form.organization = this.$route.query.orgId
		}

	},
	methods: {
		getlist() {
			contentApiQueryByOrg(this.form).then(res => {
				if (res.code == 0) {
					this.tablelist = res.data
          console.log("数据列表：",this.tablelist);
        }
			})
		},
		// link(id) {
		// 	this.form.columnId = id
		// 	this.getlist()
		// },
		link(id) {
			let _this = this
      _this.form.columnId = id
      console.log("标题",_this.$route.query.title);
      if(_this.$route.query.title){ // 从主页点击各地动态进来的数据
        /*this.$router.push({
          name: 'listpage',
          query:  { id: id, navId: 14 , title: _this.$route.query.title ,orgId: _this.$route.query.orgId}
        })*/
        _this.getlist();
      }else{
        this.$router.push({
          name: 'articlelistpage',
          query: { navId: _this.$route.query.navId, id: id }
        })
      }
      /*let routeData = this.$router.resolve({
        name: 'articlelistpage',
        query: { navId: _this.$route.query.navId, id: id }
      })
      window.open(routeData.href, '_blank')*/
			// queryFilterColumn().then(res=>{
            //     if(res.code == 0){
			// 		console.log(res);
            //         let array =[]
            //         array = res.data.map(item=>{
            //             return item.id
            //         })

			// 		_this.ids = array.join(",")
			// 		if(_this.ids && _this.ids.includes(id)){
			// 			_this.$message.warning("无权限查看该栏目")
			// 		}else{
			// 			this.$router.push({
			// 				name: 'articlelistpage',
			// 				query: { navId: _this.$route.query.navId, id: id }
			// 			})

			// 		}
			// 	}
		// })
		},
		opendetails(id) {
			/*this.$router.push({
				name: 'articlecontent',
				query: { id: id, navId: this.$route.query.navId }
			})*/
      let routeData = this.$router.resolve({
        name: 'articlecontent',
        query: { id: id, navId: this.$route.query.navId }
      })
      window.open(routeData.href, '_blank')
		},
		// 精彩瞬间详情
		openjcsj(id) {
			/*this.$router.push({
				name: 'jcsjdetails',
				query: { id: id, navId: this.$route.query.navId }
			})*/
      let routeData = this.$router.resolve({
        name: 'jcsjdetails',
        query: { id: id, navId: this.$route.query.navId }
      })
      window.open(routeData.href, '_blank')
		},
		search(val){
      this.$router.push({
          name: 'searchresult',
          query:{formdata: JSON.stringify(val)}
      })

      /*let routeData = this.$router.resolve({
        name: 'searchresult',
        query:{formdata: JSON.stringify(val)}
      })
      window.open(routeData.href, '_blank')*/
    },
		// 获取下载中心子栏目
		getdownlist() {
			let data = {
				name: "",
				code: "",
				parentId: this.$route.query.id,
			};
			columnqueryAll(data).then((res) => {
				if (res.code == 0) {
					this.columnList = res.data.map(item => {
						item.children = []
						contentApiqueryAll({ columnId: item.id }).then(reult => {
							if (reult.code == 0) {
								item.children = reult.data
							}
						})
						return item
					})
				}
			});
		},
		// 点击下载
		down(url) {
			console.log(url);
			window.open("/show" + url,"_blank")
		},
	},
};
</script>
<style scoped>
@import "../assets/css/font/iconfont.css";
@import "../assets/css/index.css";
@import "../assets/css/style.css";
</style>
